package net.mcreator.makecustomitem.procedure;

import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.common.MinecraftForge;

import net.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;

import net.mcreator.makecustomitem.ElementsMakecustomitemMod;

import java.util.Map;

@ElementsMakecustomitemMod.ModElement.Tag
public class ProcedureAttribute3 extends ElementsMakecustomitemMod.ModElement {
	public ProcedureAttribute3(ElementsMakecustomitemMod instance) {
		super(instance, 13);
	}

	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			System.err.println("Failed to load dependency entity for procedure Attribute3!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		if ((((((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) > 0) && ((entity.getEntityData().getBoolean("ItemRegen")) == (false)))) {
			entity.getEntityData().setDouble("ItemRegenSave",
					(((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY)
									.getTagCompound().getDouble("Regen")
							: -1));
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) + (entity.getEntityData().getDouble("ItemRegenSave"))));
			entity.getEntityData().setBoolean("ItemRegen", (true));
		} else if ((((((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("ItemRegen")) == (true)))) {
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) - (entity.getEntityData().getDouble("ItemRegenSave"))));
			entity.getEntityData().setBoolean("ItemRegen", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) > 0) && ((entity.getEntityData().getBoolean("RegenBlue1")) == (false)))) {
			entity.getEntityData().setDouble("RegenNum1",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Regen")
							: -1));
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) + (entity.getEntityData().getDouble("RegenNum1"))));
			entity.getEntityData().setBoolean("RegenBlue1", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("RegenBlue1")) == (true)))) {
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) - (entity.getEntityData().getDouble("RegenNum1"))));
			entity.getEntityData().setBoolean("RegenBlue1", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) > 0) && ((entity.getEntityData().getBoolean("RegenBlue2")) == (false)))) {
			entity.getEntityData().setDouble("RegenNum2",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Regen")
							: -1));
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) + (entity.getEntityData().getDouble("RegenNum2"))));
			entity.getEntityData().setBoolean("RegenBlue2", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("RegenBlue2")) == (true)))) {
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) - (entity.getEntityData().getDouble("RegenNum2"))));
			entity.getEntityData().setBoolean("RegenBlue2", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) > 0) && ((entity.getEntityData().getBoolean("RegenBlue3")) == (false)))) {
			entity.getEntityData().setDouble("RegenNum3",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Regen")
							: -1));
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) + (entity.getEntityData().getDouble("RegenNum3"))));
			entity.getEntityData().setBoolean("RegenBlue3", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("RegenBlue3")) == (true)))) {
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) - (entity.getEntityData().getDouble("RegenNum3"))));
			entity.getEntityData().setBoolean("RegenBlue3", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) > 0) && ((entity.getEntityData().getBoolean("RegenBlue4")) == (false)))) {
			entity.getEntityData().setDouble("RegenNum4",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Regen")
							: -1));
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) + (entity.getEntityData().getDouble("RegenNum4"))));
			entity.getEntityData().setBoolean("RegenBlue4", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Regen")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("RegenBlue4")) == (true)))) {
			entity.getEntityData().setDouble("Regen",
					((entity.getEntityData().getDouble("Regen")) - (entity.getEntityData().getDouble("RegenNum4"))));
			entity.getEntityData().setBoolean("RegenBlue4", (false));
		}
	}

	@SubscribeEvent
	public void onPlayerTick(TickEvent.PlayerTickEvent event) {
		if (event.phase == TickEvent.Phase.END) {
			Entity entity = event.player;
			World world = entity.world;
			int i = (int) entity.posX;
			int j = (int) entity.posY;
			int k = (int) entity.posZ;
			java.util.HashMap<String, Object> dependencies = new java.util.HashMap<>();
			dependencies.put("x", i);
			dependencies.put("y", j);
			dependencies.put("z", k);
			dependencies.put("world", world);
			dependencies.put("entity", entity);
			dependencies.put("event", event);
			this.executeProcedure(dependencies);
		}
	}

	@Override
	public void preInit(FMLPreInitializationEvent event) {
		MinecraftForge.EVENT_BUS.register(this);
	}
}
